#!/bin/bash

date=`date "+%F %T"`
head="System information as of: $date"

kernel=`uname -r`
hostname=`echo $HOSTNAME`

echo -e "\033[30;32m"
echo "**********欢迎登陆本应用服务器***********"
echo "******************************************"
echo "主机名："
hostname
echo "******************************************"
echo "本次登录的用户是："
whoami
echo "******************************************"
echo "当前登录ip："
IP=`netstat -atn |grep -i :22 | awk '{print $5}' | awk -F: '{print $1}' | sort -nr | uniq -c`
echo $IP
echo "******************************************"

echo "系统时间："
date
echo "******************************************"
echo "系统运行时间及负载："
uptime
echo "******************************************"
echo "磁盘使用情况："
df -H
echo "******************************************"
echo "内存使用情况："
free -g
echo "******************************************"
echo "最近10次系统登录情况："
last -10
echo "******************************************"
echo "当前在线用户："
w
echo "******************************************"
echo "当前系统情况请输入命令top！"
echo "******************************************"
echo ""
echo -e "\033[0m"

echo "用户：$(whoami) 在 主机：$(hostname) 已登录,登录IP：${IP}"|mail -v -s "ssh远程登录通知" ${ADMIN_EMAIL} > /dev/null 2>&1 &